(function ($, doc) {
    $.init();
    var home = {
        fn_slide_remove: function () {
            mui(".home-list")
                .on('tap', '.delete', function (event) {
                    var list = Zepto(this).parents('li')
                    list.remove()
                })
        },
        fn_btn: function () {
            // var $j=jQuery.noConflict();
            Zepto("body")
                .on("touchstart", function (e) {
                    e.preventDefault();
                    startX = e.changedTouches[0].pageX,
                    startY = e.changedTouches[0].pageY;
                });

            Zepto("body").on("touchmove", function (e) {
                e.preventDefault();
                moveEndX = e.changedTouches[0].pageX,
                moveEndY = e.changedTouches[0].pageY,
                X = moveEndX - startX,
                Y = moveEndY - startY;
                if (Math.abs(X) > Math.abs(Y) && X > 0) {
                    //  console.log("left 2 right");
                } else if (Math.abs(X) > Math.abs(Y) && X < 0) {
                    //  console.log("right 2 left");
                } else if (Math.abs(Y) > Math.abs(X) && Y > 0) {
                    // alert("top 2 bottom");
                    console.log('down');
                        Zepto('.btn-wrap').show()
                } else if (Math.abs(Y) > Math.abs(X) && Y < 0) {
                    // alert("bottom 2 top");
                    console.log('up');
                    Zepto('.btn-wrap').fadeOut()
                } else {
                    console.log("just touch");
                }

            });
        },
        fn_toggle:function(){
            Zepto(".home-list .home-list-topic").on('tap',function(){
                var parents=Zepto(this).parents('.home-list')
                if( parents.hasClass('active')){
                    parents.removeClass('active').find('.home-list-chart').hide()
                }else{
                    parents.addClass('active').find('.home-list-chart').show()
                }
                
            })
            Zepto(".home-list .chart-title .text").on('tap',function(){
                var parents=Zepto(this).parents('.chart')
                parents.hide().siblings('.chart').show()
            })

        },
        init: function () {
            this.fn_slide_remove();
            this.fn_btn();
            this.fn_toggle();
        }
    }
    $.ready(function () {
        home.init()
    });
})(mui, document);